//
//  WBBaseNavController.swift
//  SinaWeibo
//
//  Created by zhuangqianwei on 16/11/12.
//  Copyright © 2016年 zhuangqianwei. All rights reserved.
//

import UIKit

class WBBaseNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        /*
          这里可以设置返回按钮的样式和状态
          push的时候隐藏底部的tabbar
          右上角的按钮的样式和状态
        */
        
    }
   //重写push方法 ，说明NavgationController中执行了push操作
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        let count = childViewControllers.count
        
        if count > 0 {
            //push了
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: "返回", target: self, action: #selector(back))
            
            //隐藏tabbar
            viewController.hidesBottomBarWhenPushed = true
        }
        
            super.pushViewController(viewController, animated: animated)
        
        
    }
    
   
    
    //返回按钮的点击事件
         @objc private func back() {
        
        self.popViewController(animated: true)
        
        
    }
    
    
    
    
    
}
